doctype html
html
    include includes/head.pug
    body.maximized(data-manage-window)
        root-tag
        div#loading Loading…
        script.
            try {
                require('gulp');
                /* eslint no-console: 0 */
                console.log(`
            ╭──────────────────────────────────────────╮
            │                                          ├──╮
            │           O-o-oh, a developer!           │  │
            │                                          │  │
            │   If you have recently pulled changes    │  │
            │   and face issues unseen before, run     │  │
            │   this command in your console:          │  │
            │                                          │  │
            │   $ gulp -f devSetup.gulpfile.js         │  │
            │                                          │  │
            ╰─┬────────────────────────────────────────╯  │
              ╰───────────────────────────────────────────╯
                `);
            } catch (e) {
                void e;
            }
        script.
            process.versions.ctjs = require('./package.json').version;
        script(src="node_modules/pixi.js-legacy/dist/pixi-legacy.min.js")
        script(src="data/ct.release/DragonBones.min.js")
        script(src="node_modules/pixi-particles/dist/pixi-particles.min.js")
        script.
            /* So that WebGL contexts are taken from one page,
               even if PIXI was called from the background page,
               which is used for node modules
            */
            global.PIXI = PIXI;
        script.
            // A polyfill for different nw.js versions
            if (!window.__dirname) {
                window.__dirname = global.__dirname;
            }
        script(src="data/bundle.js")
        script(src="data/riotTags.js")
        script.
            // @see https://github.com/microsoft/monaco-editor-samples/blob/master/nwjs-amd-v2/index.html
            (function loadMonaco() {
                var eRequire = require('monaco-editor/min/vs/loader.js');
                // __dirname == root path of you application
                eRequire.config({
                    baseUrl: 'file:///' + global.__dirname.replace(/\\/g, '\\\\') + '/node_modules/monaco-editor/min/'
                });
                // workaround monaco-css not understanding the environment
                self.module = void 0;
                // workaround monaco-typescript not understanding the environment
                self.process.browser = true;
                eRequire(['vs/editor/editor.main'], function onMonacoLoad() {
                    window.monaco = global.monaco;

                    const themeManager = require('./data/node_requires/themes');
                    themeManager.loadBuiltInThemes();
                    // To rollback to a default theme if the set one is inaccessible ⤵
                    themeManager.loadTheme();

                    // Extended typescript tokenizer
                    const typescript = require('./data/node_requires/typescriptTokenizer.js').language;
                    // I have no guilt of this solution
                    // @see https://github.com/microsoft/monaco-editor/issues/884
                    monaco.editor.create(document.createElement('textarea'), {
                        language: 'typescript',
                        value: '(:'
                    });
                    setTimeout(() => {
                        monaco.languages.setMonarchTokensProvider('typescript', typescript);
                    }, 1000);

                    window.signals = window.signals || riot.observable({});
                    window.orders = window.orders || riot.observable({});
                    window.signals.trigger('monacoBooted');
                });
            })();
        script.
            'use strict';
            window.signals = window.signals || riot.observable({});
            window.hotkeys = require('./data/node_requires/hotkeys')(document);
            riot.mount('*');
            setTimeout(() => {
                document.getElementById('loading').classList.add('fadeout');
            }, 0);
